<?php #блок ссылок постраничной навигации

class pagination extends Load_use
{
	function getBlock()
	{		
		$pagination_param=$this->getParam('pagination_param','pnum');
		$arr=getPagination($this->getParam('total',0),$this->getParam('limit',0),$this->getParam('links_count',2),array('first_last_links'=>false,'pagination_get'=>$pagination_param,'url_after'=>$this->getParam('url_after',''),'url_before'=>'?'.preg_replace('@&'.$pagination_param.'=\d+@','',$_SERVER['QUERY_STRING']).'&'));
		$res='';
		if($arr)
		{
			$res.='<div class="pagination">'
				.(!empty($arr['prev'])?'<a href="'.$arr['prev'].'">«</a>':'')
				.(!empty($arr['first'])?'<a href="'.$arr['first'].'">1</a>...':'');
				foreach($arr as $ind=>$link)
					if(is_numeric($ind))
						$res.=$link==false?'<span class="current">'.$ind.'</span>':'<a href="'.$link.'">'.$ind.'</a>';
			$res.=(!empty($arr['last'])?'...<a href="'.$arr['last']['link'].'">'.$arr['last']['num'].'</a>':'')
				.(isset($arr['next'])?'<a href="'.$arr['next'].'">»</a>':'')
				.'</div>';
		}
		return $res;
	}
	
}